package com.hubusugon.st.test.service.Impl;

import com.hubusugon.st.test.bean.Person;
import com.hubusugon.st.test.mapper.PersonMapper;
import com.hubusugon.st.test.service.PersonService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PersonImpl implements PersonService {
    @Resource
    PersonMapper personMapper;

    public List<Person> findPerson(){
        return personMapper.findPerson();
    }

    public String addPerson(Person person) {
        try {
            personMapper.addPerson(person);
            return "success";
        } catch (Exception e) {
            return ("error"+e);
        }
    }

    public  String deletePerson(Person person){
        try{
            personMapper.deletePerson(person);
            return "success";
        }catch (Exception e){
            return ("error"+e);
        }
    }

    public String updatePerson(Person person){
        try {
            personMapper.updatePerson(person);
            return "success";
        }catch (Exception e){
            return ("error:"+e);
        }
    }
}
